# Author:Yiye
# -*- codeing = utf-8 -*-
# @Time :2021/11/12 14:00
# @Author:李卓
# @Site : 
# @File : 微博的cookie登录.py
# @Software : PyCharm
import urllib.request
import urllib.parse

url = 'https://weibo.com/ajax/statuses/mymblog?uid=2241129930&page=1&feature=0'
headers = {
    'authority':' weibo.com',
    'method':' GET',
    'path':' /ajax/statuses/mymblog?uid=2241129930&page=1&feature=0',
    'scheme':' https',
    'accept':' application/json, text/plain, */*',
    #'accept-encoding':' gzip, deflate, br',
    'accept-language':' zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
    'Cookie': 'SINAGLOBAL=8993109551553.268.1589972410024; ULV=1625755188836:13:1:1:9123349070596.336.1625755188770:1598354625445; SUBP=0033WrSXqPxfM725Ws9jqgMF55529P9D9WWYh8ENWXmgaiGuw5a1Dp1R5JpX5KMhUgL.FoMX1KMXeo5Ne0.2dJLoIp7LxKML1KBLBKnLxKqL1hnLBoMNSh.NShz7S0e4; ALF=1668238720; SSOLoginState=1636702720; SCF=AvIF-NZ7CFEpnHUcYCSfeKHQjVGJQTBFd6cd4IDw0_E6afinut3oLMIorY-ef9A4-0_eVSka_qmUr7MLG6O0kEA.; SUB=_2A25MimpQDeRhGeFK4lUV8i7LyDWIHXVv_tyYrDV8PUNbmtAKLWSnkW9NQqA4tYtOcTt4_iYeBdnreZsDZjSkwnAe; XSRF-TOKEN=qHk6n-o-qam3YBAwjPV3FI1S; WBPSESS=6-XyTdLlPV8Zcuke6Ery50WP9Us2jV9EgnR4LBxFfpkAS1W-_OH2aYREOf9BmOJfM-p5Y_6LNysuRj-3LI6ky9s46sbfBVwQgef4gnM-EkxiBD967wHp3_bDToTnpv6ARP-vR4b6afx2Ckkq3iPy_w==',
    'referer': 'https://weibo.com/u/2241129930?tabtype=feed',
    'sec-ch-ua':' "Chromium";v="94", "Google Chrome";v="94", ";Not A Brand";v="99"',
    'sec-ch-ua-mobile':' ?0',
    'sec-ch-ua-platform':' "Windows"',
    'sec-fetch-dest':' empty',
    'sec-fetch-mode':' cors',
    'sec-fetch-site':' same-origin',
    'traceparent':' 00-fac75e9fe8b6941609f3550029316ebc-d8650043e0fb38de-00',
    'user-agent':' Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36',
    'x-requested-with':' XMLHttpRequest',
    'x-xsrf-token':' qHk6n-o-qam3YBAwjPV3FI1S',
}

respect = urllib.request.Request(url=url,headers=headers)
rsponse = urllib.request.urlopen(respect)
content = rsponse.read().decode('utf-8')
print(content)
with open('weibo.html', 'w', encoding='utf-8') as fp:
    fp.write(content)